﻿//  ***** Guidance generated code © Catharsis ***** //
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
using Spring.Context;
using Spring.Context.Support;
using Huirui.Cavan.Core.Settings;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using Huirui.Cavan.Application.MainBoundedContext.SystemModule;
using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;

namespace Huirui.Cavan.Application.MainBoundedContext.Setting
{
    /// <summary>
    ///     This class reads the "Project.config" file and converts it 
    ///     into the IBaseSettings object. If any bugs or incorrectness appears in the .config file
    ///     default BaseSettings object values are used
    /// </summary>
    public class ProjectSettingsProvider : IBaseSettingsProvider, IProjectSettingsProvider
    {
        #region public IBaseSettings
        protected virtual ProjectSettings Settings
        {
            get
            {
                IApplicationContext ctx =  ContextRegistry.GetContext();

                var settings = ctx.GetObject("ProjectSettings") as ProjectSettings;
                return settings;
            }
        }

        protected virtual UserSettings USettings
        {
            get 
            {
                var settings = new UserSettings();

                return settings;
            }
        }


        #region IBaseSettingsProvider Members
        /// <summary>
        ///     The project dependent settings from the Project.config
        /// </summary>
        public virtual IBaseSettings BaseSettings
        {
            get { return Settings; }
        }
        #endregion

        #region IProjectSettingsProvider Members
        public virtual IProjectSettings ProjectSettings
        {
            get { return Settings; }
        }

        public virtual IUserSettings UserSettings
        {
            get { return USettings; }
        }
        #endregion

        #endregion public IBaseSettings
    }
}